import React, { useState } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import './App.css';
import { globalContext } from './context';
import { HomePage } from './pages/Home';
import { ImagePage } from './pages/Image';
import { NotFound } from './pages/NotFound';
import { PlayPage } from './pages/Play';

export const initDirectory = 'E:\\迅雷下载';

function App () {
  const [directory, setDirectory] = useState<string[]>([initDirectory]);
  const [rootFolders, setRootFolders] = useState<string[]>([initDirectory]);
  const [rtl, setRtl] = useState<boolean>(true);
  return (
    <div className="App">
      <globalContext.Provider value={{
        directory,
        setDirectory,
        rootFolders,
        setRootFolders,
        rtl,
        setRtl,
      }}>
        <Router>
          <Switch>
            <Route path="/" component={HomePage} exact/>
            <Route path="/video" component={PlayPage} exact/>
            <Route path="/image" component={ImagePage} exact/>
            <Route path="*" component={NotFound}/>
          </Switch>
        </Router>
      </globalContext.Provider>
    </div>
  );
}

export default App;
